package com.buaa.aimall.goodsModule.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.buaa.aimall.goodsModule.Entity.CollectEntity;
import com.buaa.aimall.goodsModule.Mapper.CollectMapper;
import org.springframework.stereotype.Service;

import java.util.Set;
import java.util.stream.Collectors;

@Service
public class CollectServiceImpl extends ServiceImpl<CollectMapper, CollectEntity> implements CollectService {
    /**
     *
     * @param userId
     * @return Set
     * @author zyt
     */
    @Override
    public Set<String> getCollectedComputeIdsByUser(String userId) {
        return this.lambdaQuery()
                .eq(CollectEntity::getUser, userId)
                .isNotNull(CollectEntity::getCompute)
                .list()
                .stream()
                .map(CollectEntity::getCompute)
                .collect(Collectors.toSet());
    }
}
